package com.zhuss.advice.proposal;

import com.zhuss.bean.bo.advice.Complaint.CreateComplaintBo;
import com.zhuss.bean.bo.advice.Complaint.weChat.CreateComplaintWeChatBo;
import com.zhuss.bean.bo.advice.proposal.CreateProposalBo;
import com.zhuss.bean.bo.advice.proposal.DeleteProposalBo;
import com.zhuss.bean.bo.advice.proposal.UpdateProposalBo;
import com.zhuss.bean.bo.advice.proposal.weChat.CreateProposalWeChatBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * @Author: zhushanshuo
 * @Date: 2020/3/6 9:05
 */
@Component("proposalOperateService")
public class ProposalOperateService implements OperateService<Void, Object> {

    @Autowired
    @Qualifier("proposalCreate")
    private Processor<Object, CreateProposalBo> proposalCreate;

    @Autowired
    @Qualifier("proposalUpdate")
    private Processor<Object, UpdateProposalBo> proposalUpdate;

    @Autowired
    @Qualifier("proposalDelete")
    private Processor<Object, DeleteProposalBo> proposalDelete;

    /**
     * 新建
     * @return
     * @throws WpsException
     */
    @Override
    public Void create(Object o) throws WpsException {
        CreateProposalBo bo = (CreateProposalBo) o;
        proposalCreate.process(bo);
        return null;
    }

    /**
     * 修改
     * @return
     * @throws WpsException
     */
    @Override
    public Void update(Object o) throws WpsException {
        UpdateProposalBo bo = (UpdateProposalBo) o;
        proposalUpdate.process(bo);
        return null;
    }

    /**
     * 删除
     * @return
     * @throws WpsException
     */
    @Override
    public Void delete(Object o) throws WpsException {
        DeleteProposalBo bo = (DeleteProposalBo) o;
        proposalDelete.process(bo);
        return null;
    }

    /**
     * 微信新建
     * @throws WpsException
     */
    public Void weChatCreate(Object o) throws WpsException {
        CreateProposalWeChatBo bo = (CreateProposalWeChatBo) o;
        CreateProposalBo cpb = new CreateProposalBo();
        BeanUtils.copyProperties(bo,cpb);
        proposalCreate.process(cpb);
        return null;
    }
}
